﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace XNA
{
    public abstract class VisibleGameEntity : GameEntity
    {
        protected List<MySprite> sprites;
        protected int nSprites;
        protected Vector2 _TopLeft;
        protected Vector2 _Size;

        public Vector2 TopLeft
        {
            get { return _TopLeft; }
            set { _TopLeft = value; }
        }

        public Vector2 Size
        {
            get { return _Size; }
            set { _Size = value; }
        }

        public virtual void Update(GameTime gameTime)
        {
            for (int i = 0; i < nSprites; i++)
            {
                sprites[i].Update(gameTime);
            }
        }

        public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            for (int i = 0; i < nSprites; i++)
            {
                sprites[i].Draw(gameTime,spriteBatch);
            }
        }

        public virtual bool IsClicked(Vector2 point)
        {
            if (point.X >= TopLeft.X &&
                point.X <= TopLeft.X + Size.X &&
                point.Y >= TopLeft.Y &&
                point.Y <= TopLeft.Y + Size.Y)
                return true;
            return false;
        }
    }
}
